package com.yf.controller.api;

import com.yf.annotation.IgnoreAuth;
import com.yf.response.R;
import com.yf.service.SocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/socket")
public class SocketTestController {

    @Autowired
    private SocketService socketService;

    @RequestMapping("/start")
    @IgnoreAuth
    public R startServer(){
        System.out.println("服务启动了!");
        socketService.startWebServer("/ws",9091);
        return R.ok();
    }

    @RequestMapping("/stop")
    @IgnoreAuth
    public R stopServer(){
        socketService.stopWebServer();
        System.out.println("服务关闭了!");
        return R.ok();
    }


}
